<?php
    namespace  Home\Controller;
    use Think\Controller;

    class LoginController extends Controller{
        public  function  index(){
            $this->display();
        }
        public  function  dologin(){
            //var_dump($_POST);exit;
            $data['name']=I("post.name");
            $data['pwd']=md5(I("post.pwd"));
            //实例化model类
            $userModel=M('user');
            $res=$userModel->where($data)->find();
           // echo $userModel->getLastSql();
            //var_dump($res);exit;
            if ($res){
                echo 1;
                session('home',$data['name']);
            }else{
                echo 0;
            }
        }

        public function loginout(){
            session('home',null); // 删除name
            $this->redirect('Login/index');
        }
    }
?>